package org.lex.dbq.model.jdbc.meta;

import java.util.Comparator;

public class KeyVo {
	public static final Comparator<KeyVo> COMPARATOR = new Comparator<KeyVo>() {
		@Override
		public int compare(KeyVo o1, KeyVo o2) {
			if (o1.type == o2.type) {
				return o1.ordinal - o2.ordinal;
			} else {
				return o1.type.ordinal() - o2.type.ordinal();
			}
		}
	};
	public static final String[] COLUMN_NAMES = { "Name", "Type", "Columns", "Reference Table", "Reference Column" };

	public enum KeyType {
		PRIMARY, UNIQUE, FOREIGN
	}

	public String name = "";
	public KeyType type = null;
	public String columns = "";
	public String referenceTable = "";
	public String referenceColumn = "";
	public int ordinal;

	public String getLabel(int col) {
		switch (col) {
		case 0:
			return name;
		case 1:
			return type.name();
		case 2:
			return columns;
		case 3:
			return referenceTable;
		case 4:
			return referenceColumn;
		default:
			return "";
		}
	}
}
